package org.jeecg.modules.crm.controller;

import org.jeecg.common.system.query.QueryGenerator;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import java.util.Arrays;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.crm.entity.SalesKitDescription;
import org.jeecg.modules.crm.entity.SalesKitPriceChart;
import org.jeecg.modules.crm.entity.SalesKitSitePlan;
import org.jeecg.modules.crm.entity.SalesKitUnitPlan;
import org.jeecg.modules.crm.entity.SalesKitFacilities;
import org.jeecg.modules.crm.entity.SalesKitGallery;
import org.jeecg.modules.crm.entity.SalesKitVideo;
import org.jeecg.modules.crm.entity.SalesKitDocument;
import org.jeecg.modules.crm.entity.SalesKitFaq;
import org.jeecg.modules.crm.entity.SalesKit;
import org.jeecg.modules.crm.service.ISalesKitService;
import org.jeecg.modules.crm.service.ISalesKitDescriptionService;
import org.jeecg.modules.crm.service.ISalesKitPriceChartService;
import org.jeecg.modules.crm.service.ISalesKitSitePlanService;
import org.jeecg.modules.crm.service.ISalesKitUnitPlanService;
import org.jeecg.modules.crm.service.ISalesKitFacilitiesService;
import org.jeecg.modules.crm.service.ISalesKitGalleryService;
import org.jeecg.modules.crm.service.ISalesKitVideoService;
import org.jeecg.modules.crm.service.ISalesKitDocumentService;
import org.jeecg.modules.crm.service.ISalesKitFaqService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

 /**
 * @Description: Sales Kit
 * @Author: jeecg-boot
 * @Date:   2025-04-22
 * @Version: V1.0
 */
@Api(tags="Sales Kit")
@RestController
@RequestMapping("/crm/salesKit")
@Slf4j
public class SalesKitController extends JeecgController<SalesKit, ISalesKitService> {

	@Autowired
	private ISalesKitService salesKitService;

	@Autowired
	private ISalesKitDescriptionService salesKitDescriptionService;

	@Autowired
	private ISalesKitPriceChartService salesKitPriceChartService;

	@Autowired
	private ISalesKitSitePlanService salesKitSitePlanService;

	@Autowired
	private ISalesKitUnitPlanService salesKitUnitPlanService;

	@Autowired
	private ISalesKitFacilitiesService salesKitFacilitiesService;

	@Autowired
	private ISalesKitGalleryService salesKitGalleryService;

	@Autowired
	private ISalesKitVideoService salesKitVideoService;

	@Autowired
	private ISalesKitDocumentService salesKitDocumentService;

	@Autowired
	private ISalesKitFaqService salesKitFaqService;


	/*---------------------------------主表处理-begin-------------------------------------*/

	/**
	 * 分页列表查询
	 * @param salesKit
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "Sales Kit-分页列表查询")
	@ApiOperation(value="Sales Kit-分页列表查询", notes="Sales Kit-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<SalesKit>> queryPageList(SalesKit salesKit,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<SalesKit> queryWrapper = QueryGenerator.initQueryWrapper(salesKit, req.getParameterMap());
		Page<SalesKit> page = new Page<SalesKit>(pageNo, pageSize);
		IPage<SalesKit> pageList = salesKitService.page(page, queryWrapper);
		return Result.OK(pageList);
	}

	/**
     *   添加
     * @param salesKit
     * @return
     */
    @AutoLog(value = "Sales Kit-添加")
    @ApiOperation(value="Sales Kit-添加", notes="Sales Kit-添加")
    //@RequiresPermissions("org.jeecg.modules:sales_kit:add")
    @PostMapping(value = "/add")
    public Result<String> add(@RequestBody SalesKit salesKit) {
        salesKitService.save(salesKit);
        return Result.OK("添加成功！");
    }

    /**
     *  编辑
     * @param salesKit
     * @return
     */
    @AutoLog(value = "Sales Kit-编辑")
    @ApiOperation(value="Sales Kit-编辑", notes="Sales Kit-编辑")
    //@RequiresPermissions("org.jeecg.modules:sales_kit:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
    public Result<String> edit(@RequestBody SalesKit salesKit) {
        salesKitService.updateById(salesKit);
        return Result.OK("编辑成功!");
    }

    /**
     * 通过id删除
     * @param id
     * @return
     */
    @AutoLog(value = "Sales Kit-通过id删除")
    @ApiOperation(value="Sales Kit-通过id删除", notes="Sales Kit-通过id删除")
    //@RequiresPermissions("org.jeecg.modules:sales_kit:delete")
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name="id",required=true) String id) {
        salesKitService.delMain(id);
        return Result.OK("删除成功!");
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @AutoLog(value = "Sales Kit-批量删除")
    @ApiOperation(value="Sales Kit-批量删除", notes="Sales Kit-批量删除")
    //@RequiresPermissions("org.jeecg.modules:sales_kit:deleteBatch")
    @DeleteMapping(value = "/deleteBatch")
    public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
        this.salesKitService.delBatchMain(Arrays.asList(ids.split(",")));
        return Result.OK("批量删除成功!");
    }

    /**
     * 导出
     * @return
     */
    //@RequiresPermissions("org.jeecg.modules:sales_kit:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, SalesKit salesKit) {
        return super.exportXls(request, salesKit, SalesKit.class, "Sales Kit");
    }

    /**
     * 导入
     * @return
     */
    //@RequiresPermissions("org.jeecg.modules:sales_kit:importExcel")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, SalesKit.class);
    }
	/*---------------------------------主表处理-end-------------------------------------*/


    /*--------------------------------子表处理-Sales Kit Description-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "Sales Kit Description-通过主表ID查询")
	@ApiOperation(value="Sales Kit Description-通过主表ID查询", notes="Sales Kit Description-通过主表ID查询")
	@GetMapping(value = "/listSalesKitDescriptionByMainId")
    public Result<IPage<SalesKitDescription>> listSalesKitDescriptionByMainId(SalesKitDescription salesKitDescription,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<SalesKitDescription> queryWrapper = QueryGenerator.initQueryWrapper(salesKitDescription, req.getParameterMap());
        Page<SalesKitDescription> page = new Page<SalesKitDescription>(pageNo, pageSize);
        IPage<SalesKitDescription> pageList = salesKitDescriptionService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param salesKitDescription
	 * @return
	 */
	@AutoLog(value = "Sales Kit Description-添加")
	@ApiOperation(value="Sales Kit Description-添加", notes="Sales Kit Description-添加")
	@PostMapping(value = "/addSalesKitDescription")
	public Result<String> addSalesKitDescription(@RequestBody SalesKitDescription salesKitDescription) {
		salesKitDescriptionService.save(salesKitDescription);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param salesKitDescription
	 * @return
	 */
	@AutoLog(value = "Sales Kit Description-编辑")
	@ApiOperation(value="Sales Kit Description-编辑", notes="Sales Kit Description-编辑")
	@RequestMapping(value = "/editSalesKitDescription", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editSalesKitDescription(@RequestBody SalesKitDescription salesKitDescription) {
		salesKitDescriptionService.updateById(salesKitDescription);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "Sales Kit Description-通过id删除")
	@ApiOperation(value="Sales Kit Description-通过id删除", notes="Sales Kit Description-通过id删除")
	@DeleteMapping(value = "/deleteSalesKitDescription")
	public Result<String> deleteSalesKitDescription(@RequestParam(name="id",required=true) String id) {
		salesKitDescriptionService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "Sales Kit Description-批量删除")
	@ApiOperation(value="Sales Kit Description-批量删除", notes="Sales Kit Description-批量删除")
	@DeleteMapping(value = "/deleteBatchSalesKitDescription")
	public Result<String> deleteBatchSalesKitDescription(@RequestParam(name="ids",required=true) String ids) {
	    this.salesKitDescriptionService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportSalesKitDescription")
    public ModelAndView exportSalesKitDescription(HttpServletRequest request, SalesKitDescription salesKitDescription) {
		 // Step.1 组装查询条件
		 QueryWrapper<SalesKitDescription> queryWrapper = QueryGenerator.initQueryWrapper(salesKitDescription, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<SalesKitDescription> pageList = salesKitDescriptionService.list(queryWrapper);
		 List<SalesKitDescription> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "Sales Kit Description");
		 mv.addObject(NormalExcelConstants.CLASS, SalesKitDescription.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("Sales Kit Description报表", "导出人:" + sysUser.getRealname(), "Sales Kit Description"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importSalesKitDescription/{mainId}")
    public Result<?> importSalesKitDescription(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<SalesKitDescription> list = ExcelImportUtil.importExcel(file.getInputStream(), SalesKitDescription.class, params);
				 for (SalesKitDescription temp : list) {
                    temp.setMainId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 salesKitDescriptionService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-Sales Kit Description-end----------------------------------------------*/

    /*--------------------------------子表处理-Sales Kit Price Chart-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "Sales Kit Price Chart-通过主表ID查询")
	@ApiOperation(value="Sales Kit Price Chart-通过主表ID查询", notes="Sales Kit Price Chart-通过主表ID查询")
	@GetMapping(value = "/listSalesKitPriceChartByMainId")
    public Result<IPage<SalesKitPriceChart>> listSalesKitPriceChartByMainId(SalesKitPriceChart salesKitPriceChart,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<SalesKitPriceChart> queryWrapper = QueryGenerator.initQueryWrapper(salesKitPriceChart, req.getParameterMap());
        Page<SalesKitPriceChart> page = new Page<SalesKitPriceChart>(pageNo, pageSize);
        IPage<SalesKitPriceChart> pageList = salesKitPriceChartService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param salesKitPriceChart
	 * @return
	 */
	@AutoLog(value = "Sales Kit Price Chart-添加")
	@ApiOperation(value="Sales Kit Price Chart-添加", notes="Sales Kit Price Chart-添加")
	@PostMapping(value = "/addSalesKitPriceChart")
	public Result<String> addSalesKitPriceChart(@RequestBody SalesKitPriceChart salesKitPriceChart) {
		salesKitPriceChartService.save(salesKitPriceChart);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param salesKitPriceChart
	 * @return
	 */
	@AutoLog(value = "Sales Kit Price Chart-编辑")
	@ApiOperation(value="Sales Kit Price Chart-编辑", notes="Sales Kit Price Chart-编辑")
	@RequestMapping(value = "/editSalesKitPriceChart", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editSalesKitPriceChart(@RequestBody SalesKitPriceChart salesKitPriceChart) {
		salesKitPriceChartService.updateById(salesKitPriceChart);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "Sales Kit Price Chart-通过id删除")
	@ApiOperation(value="Sales Kit Price Chart-通过id删除", notes="Sales Kit Price Chart-通过id删除")
	@DeleteMapping(value = "/deleteSalesKitPriceChart")
	public Result<String> deleteSalesKitPriceChart(@RequestParam(name="id",required=true) String id) {
		salesKitPriceChartService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "Sales Kit Price Chart-批量删除")
	@ApiOperation(value="Sales Kit Price Chart-批量删除", notes="Sales Kit Price Chart-批量删除")
	@DeleteMapping(value = "/deleteBatchSalesKitPriceChart")
	public Result<String> deleteBatchSalesKitPriceChart(@RequestParam(name="ids",required=true) String ids) {
	    this.salesKitPriceChartService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportSalesKitPriceChart")
    public ModelAndView exportSalesKitPriceChart(HttpServletRequest request, SalesKitPriceChart salesKitPriceChart) {
		 // Step.1 组装查询条件
		 QueryWrapper<SalesKitPriceChart> queryWrapper = QueryGenerator.initQueryWrapper(salesKitPriceChart, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<SalesKitPriceChart> pageList = salesKitPriceChartService.list(queryWrapper);
		 List<SalesKitPriceChart> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "Sales Kit Price Chart");
		 mv.addObject(NormalExcelConstants.CLASS, SalesKitPriceChart.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("Sales Kit Price Chart报表", "导出人:" + sysUser.getRealname(), "Sales Kit Price Chart"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importSalesKitPriceChart/{mainId}")
    public Result<?> importSalesKitPriceChart(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<SalesKitPriceChart> list = ExcelImportUtil.importExcel(file.getInputStream(), SalesKitPriceChart.class, params);
				 for (SalesKitPriceChart temp : list) {
                    temp.setMainId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 salesKitPriceChartService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-Sales Kit Price Chart-end----------------------------------------------*/

    /*--------------------------------子表处理-Site Plan-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "Site Plan-通过主表ID查询")
	@ApiOperation(value="Site Plan-通过主表ID查询", notes="Site Plan-通过主表ID查询")
	@GetMapping(value = "/listSalesKitSitePlanByMainId")
    public Result<IPage<SalesKitSitePlan>> listSalesKitSitePlanByMainId(SalesKitSitePlan salesKitSitePlan,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<SalesKitSitePlan> queryWrapper = QueryGenerator.initQueryWrapper(salesKitSitePlan, req.getParameterMap());
        Page<SalesKitSitePlan> page = new Page<SalesKitSitePlan>(pageNo, pageSize);
        IPage<SalesKitSitePlan> pageList = salesKitSitePlanService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param salesKitSitePlan
	 * @return
	 */
	@AutoLog(value = "Site Plan-添加")
	@ApiOperation(value="Site Plan-添加", notes="Site Plan-添加")
	@PostMapping(value = "/addSalesKitSitePlan")
	public Result<String> addSalesKitSitePlan(@RequestBody SalesKitSitePlan salesKitSitePlan) {
		salesKitSitePlanService.save(salesKitSitePlan);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param salesKitSitePlan
	 * @return
	 */
	@AutoLog(value = "Site Plan-编辑")
	@ApiOperation(value="Site Plan-编辑", notes="Site Plan-编辑")
	@RequestMapping(value = "/editSalesKitSitePlan", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editSalesKitSitePlan(@RequestBody SalesKitSitePlan salesKitSitePlan) {
		salesKitSitePlanService.updateById(salesKitSitePlan);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "Site Plan-通过id删除")
	@ApiOperation(value="Site Plan-通过id删除", notes="Site Plan-通过id删除")
	@DeleteMapping(value = "/deleteSalesKitSitePlan")
	public Result<String> deleteSalesKitSitePlan(@RequestParam(name="id",required=true) String id) {
		salesKitSitePlanService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "Site Plan-批量删除")
	@ApiOperation(value="Site Plan-批量删除", notes="Site Plan-批量删除")
	@DeleteMapping(value = "/deleteBatchSalesKitSitePlan")
	public Result<String> deleteBatchSalesKitSitePlan(@RequestParam(name="ids",required=true) String ids) {
	    this.salesKitSitePlanService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportSalesKitSitePlan")
    public ModelAndView exportSalesKitSitePlan(HttpServletRequest request, SalesKitSitePlan salesKitSitePlan) {
		 // Step.1 组装查询条件
		 QueryWrapper<SalesKitSitePlan> queryWrapper = QueryGenerator.initQueryWrapper(salesKitSitePlan, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<SalesKitSitePlan> pageList = salesKitSitePlanService.list(queryWrapper);
		 List<SalesKitSitePlan> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "Site Plan");
		 mv.addObject(NormalExcelConstants.CLASS, SalesKitSitePlan.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("Site Plan报表", "导出人:" + sysUser.getRealname(), "Site Plan"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importSalesKitSitePlan/{mainId}")
    public Result<?> importSalesKitSitePlan(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<SalesKitSitePlan> list = ExcelImportUtil.importExcel(file.getInputStream(), SalesKitSitePlan.class, params);
				 for (SalesKitSitePlan temp : list) {
                    temp.setMainId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 salesKitSitePlanService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-Site Plan-end----------------------------------------------*/

    /*--------------------------------子表处理-Sales Kit Unit Plan-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "Sales Kit Unit Plan-通过主表ID查询")
	@ApiOperation(value="Sales Kit Unit Plan-通过主表ID查询", notes="Sales Kit Unit Plan-通过主表ID查询")
	@GetMapping(value = "/listSalesKitUnitPlanByMainId")
    public Result<IPage<SalesKitUnitPlan>> listSalesKitUnitPlanByMainId(SalesKitUnitPlan salesKitUnitPlan,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<SalesKitUnitPlan> queryWrapper = QueryGenerator.initQueryWrapper(salesKitUnitPlan, req.getParameterMap());
        Page<SalesKitUnitPlan> page = new Page<SalesKitUnitPlan>(pageNo, pageSize);
        IPage<SalesKitUnitPlan> pageList = salesKitUnitPlanService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param salesKitUnitPlan
	 * @return
	 */
	@AutoLog(value = "Sales Kit Unit Plan-添加")
	@ApiOperation(value="Sales Kit Unit Plan-添加", notes="Sales Kit Unit Plan-添加")
	@PostMapping(value = "/addSalesKitUnitPlan")
	public Result<String> addSalesKitUnitPlan(@RequestBody SalesKitUnitPlan salesKitUnitPlan) {
		salesKitUnitPlanService.save(salesKitUnitPlan);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param salesKitUnitPlan
	 * @return
	 */
	@AutoLog(value = "Sales Kit Unit Plan-编辑")
	@ApiOperation(value="Sales Kit Unit Plan-编辑", notes="Sales Kit Unit Plan-编辑")
	@RequestMapping(value = "/editSalesKitUnitPlan", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editSalesKitUnitPlan(@RequestBody SalesKitUnitPlan salesKitUnitPlan) {
		salesKitUnitPlanService.updateById(salesKitUnitPlan);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "Sales Kit Unit Plan-通过id删除")
	@ApiOperation(value="Sales Kit Unit Plan-通过id删除", notes="Sales Kit Unit Plan-通过id删除")
	@DeleteMapping(value = "/deleteSalesKitUnitPlan")
	public Result<String> deleteSalesKitUnitPlan(@RequestParam(name="id",required=true) String id) {
		salesKitUnitPlanService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "Sales Kit Unit Plan-批量删除")
	@ApiOperation(value="Sales Kit Unit Plan-批量删除", notes="Sales Kit Unit Plan-批量删除")
	@DeleteMapping(value = "/deleteBatchSalesKitUnitPlan")
	public Result<String> deleteBatchSalesKitUnitPlan(@RequestParam(name="ids",required=true) String ids) {
	    this.salesKitUnitPlanService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportSalesKitUnitPlan")
    public ModelAndView exportSalesKitUnitPlan(HttpServletRequest request, SalesKitUnitPlan salesKitUnitPlan) {
		 // Step.1 组装查询条件
		 QueryWrapper<SalesKitUnitPlan> queryWrapper = QueryGenerator.initQueryWrapper(salesKitUnitPlan, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<SalesKitUnitPlan> pageList = salesKitUnitPlanService.list(queryWrapper);
		 List<SalesKitUnitPlan> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "Sales Kit Unit Plan");
		 mv.addObject(NormalExcelConstants.CLASS, SalesKitUnitPlan.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("Sales Kit Unit Plan报表", "导出人:" + sysUser.getRealname(), "Sales Kit Unit Plan"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importSalesKitUnitPlan/{mainId}")
    public Result<?> importSalesKitUnitPlan(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<SalesKitUnitPlan> list = ExcelImportUtil.importExcel(file.getInputStream(), SalesKitUnitPlan.class, params);
				 for (SalesKitUnitPlan temp : list) {
                    temp.setMainId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 salesKitUnitPlanService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-Sales Kit Unit Plan-end----------------------------------------------*/

    /*--------------------------------子表处理-Sales Kit Facilities-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "Sales Kit Facilities-通过主表ID查询")
	@ApiOperation(value="Sales Kit Facilities-通过主表ID查询", notes="Sales Kit Facilities-通过主表ID查询")
	@GetMapping(value = "/listSalesKitFacilitiesByMainId")
    public Result<IPage<SalesKitFacilities>> listSalesKitFacilitiesByMainId(SalesKitFacilities salesKitFacilities,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<SalesKitFacilities> queryWrapper = QueryGenerator.initQueryWrapper(salesKitFacilities, req.getParameterMap());
        Page<SalesKitFacilities> page = new Page<SalesKitFacilities>(pageNo, pageSize);
        IPage<SalesKitFacilities> pageList = salesKitFacilitiesService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param salesKitFacilities
	 * @return
	 */
	@AutoLog(value = "Sales Kit Facilities-添加")
	@ApiOperation(value="Sales Kit Facilities-添加", notes="Sales Kit Facilities-添加")
	@PostMapping(value = "/addSalesKitFacilities")
	public Result<String> addSalesKitFacilities(@RequestBody SalesKitFacilities salesKitFacilities) {
		salesKitFacilitiesService.save(salesKitFacilities);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param salesKitFacilities
	 * @return
	 */
	@AutoLog(value = "Sales Kit Facilities-编辑")
	@ApiOperation(value="Sales Kit Facilities-编辑", notes="Sales Kit Facilities-编辑")
	@RequestMapping(value = "/editSalesKitFacilities", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editSalesKitFacilities(@RequestBody SalesKitFacilities salesKitFacilities) {
		salesKitFacilitiesService.updateById(salesKitFacilities);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "Sales Kit Facilities-通过id删除")
	@ApiOperation(value="Sales Kit Facilities-通过id删除", notes="Sales Kit Facilities-通过id删除")
	@DeleteMapping(value = "/deleteSalesKitFacilities")
	public Result<String> deleteSalesKitFacilities(@RequestParam(name="id",required=true) String id) {
		salesKitFacilitiesService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "Sales Kit Facilities-批量删除")
	@ApiOperation(value="Sales Kit Facilities-批量删除", notes="Sales Kit Facilities-批量删除")
	@DeleteMapping(value = "/deleteBatchSalesKitFacilities")
	public Result<String> deleteBatchSalesKitFacilities(@RequestParam(name="ids",required=true) String ids) {
	    this.salesKitFacilitiesService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportSalesKitFacilities")
    public ModelAndView exportSalesKitFacilities(HttpServletRequest request, SalesKitFacilities salesKitFacilities) {
		 // Step.1 组装查询条件
		 QueryWrapper<SalesKitFacilities> queryWrapper = QueryGenerator.initQueryWrapper(salesKitFacilities, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<SalesKitFacilities> pageList = salesKitFacilitiesService.list(queryWrapper);
		 List<SalesKitFacilities> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "Sales Kit Facilities");
		 mv.addObject(NormalExcelConstants.CLASS, SalesKitFacilities.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("Sales Kit Facilities报表", "导出人:" + sysUser.getRealname(), "Sales Kit Facilities"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importSalesKitFacilities/{mainId}")
    public Result<?> importSalesKitFacilities(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<SalesKitFacilities> list = ExcelImportUtil.importExcel(file.getInputStream(), SalesKitFacilities.class, params);
				 for (SalesKitFacilities temp : list) {
                    temp.setMainId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 salesKitFacilitiesService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-Sales Kit Facilities-end----------------------------------------------*/

    /*--------------------------------子表处理-Sales Kit Gallery-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "Sales Kit Gallery-通过主表ID查询")
	@ApiOperation(value="Sales Kit Gallery-通过主表ID查询", notes="Sales Kit Gallery-通过主表ID查询")
	@GetMapping(value = "/listSalesKitGalleryByMainId")
    public Result<IPage<SalesKitGallery>> listSalesKitGalleryByMainId(SalesKitGallery salesKitGallery,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<SalesKitGallery> queryWrapper = QueryGenerator.initQueryWrapper(salesKitGallery, req.getParameterMap());
        Page<SalesKitGallery> page = new Page<SalesKitGallery>(pageNo, pageSize);
        IPage<SalesKitGallery> pageList = salesKitGalleryService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param salesKitGallery
	 * @return
	 */
	@AutoLog(value = "Sales Kit Gallery-添加")
	@ApiOperation(value="Sales Kit Gallery-添加", notes="Sales Kit Gallery-添加")
	@PostMapping(value = "/addSalesKitGallery")
	public Result<String> addSalesKitGallery(@RequestBody SalesKitGallery salesKitGallery) {
		salesKitGalleryService.save(salesKitGallery);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param salesKitGallery
	 * @return
	 */
	@AutoLog(value = "Sales Kit Gallery-编辑")
	@ApiOperation(value="Sales Kit Gallery-编辑", notes="Sales Kit Gallery-编辑")
	@RequestMapping(value = "/editSalesKitGallery", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editSalesKitGallery(@RequestBody SalesKitGallery salesKitGallery) {
		salesKitGalleryService.updateById(salesKitGallery);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "Sales Kit Gallery-通过id删除")
	@ApiOperation(value="Sales Kit Gallery-通过id删除", notes="Sales Kit Gallery-通过id删除")
	@DeleteMapping(value = "/deleteSalesKitGallery")
	public Result<String> deleteSalesKitGallery(@RequestParam(name="id",required=true) String id) {
		salesKitGalleryService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "Sales Kit Gallery-批量删除")
	@ApiOperation(value="Sales Kit Gallery-批量删除", notes="Sales Kit Gallery-批量删除")
	@DeleteMapping(value = "/deleteBatchSalesKitGallery")
	public Result<String> deleteBatchSalesKitGallery(@RequestParam(name="ids",required=true) String ids) {
	    this.salesKitGalleryService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportSalesKitGallery")
    public ModelAndView exportSalesKitGallery(HttpServletRequest request, SalesKitGallery salesKitGallery) {
		 // Step.1 组装查询条件
		 QueryWrapper<SalesKitGallery> queryWrapper = QueryGenerator.initQueryWrapper(salesKitGallery, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<SalesKitGallery> pageList = salesKitGalleryService.list(queryWrapper);
		 List<SalesKitGallery> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "Sales Kit Gallery");
		 mv.addObject(NormalExcelConstants.CLASS, SalesKitGallery.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("Sales Kit Gallery报表", "导出人:" + sysUser.getRealname(), "Sales Kit Gallery"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importSalesKitGallery/{mainId}")
    public Result<?> importSalesKitGallery(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<SalesKitGallery> list = ExcelImportUtil.importExcel(file.getInputStream(), SalesKitGallery.class, params);
				 for (SalesKitGallery temp : list) {
                    temp.setMainId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 salesKitGalleryService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-Sales Kit Gallery-end----------------------------------------------*/

    /*--------------------------------子表处理-Sales Kit Video-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "Sales Kit Video-通过主表ID查询")
	@ApiOperation(value="Sales Kit Video-通过主表ID查询", notes="Sales Kit Video-通过主表ID查询")
	@GetMapping(value = "/listSalesKitVideoByMainId")
    public Result<IPage<SalesKitVideo>> listSalesKitVideoByMainId(SalesKitVideo salesKitVideo,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<SalesKitVideo> queryWrapper = QueryGenerator.initQueryWrapper(salesKitVideo, req.getParameterMap());
        Page<SalesKitVideo> page = new Page<SalesKitVideo>(pageNo, pageSize);
        IPage<SalesKitVideo> pageList = salesKitVideoService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param salesKitVideo
	 * @return
	 */
	@AutoLog(value = "Sales Kit Video-添加")
	@ApiOperation(value="Sales Kit Video-添加", notes="Sales Kit Video-添加")
	@PostMapping(value = "/addSalesKitVideo")
	public Result<String> addSalesKitVideo(@RequestBody SalesKitVideo salesKitVideo) {
		salesKitVideoService.save(salesKitVideo);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param salesKitVideo
	 * @return
	 */
	@AutoLog(value = "Sales Kit Video-编辑")
	@ApiOperation(value="Sales Kit Video-编辑", notes="Sales Kit Video-编辑")
	@RequestMapping(value = "/editSalesKitVideo", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editSalesKitVideo(@RequestBody SalesKitVideo salesKitVideo) {
		salesKitVideoService.updateById(salesKitVideo);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "Sales Kit Video-通过id删除")
	@ApiOperation(value="Sales Kit Video-通过id删除", notes="Sales Kit Video-通过id删除")
	@DeleteMapping(value = "/deleteSalesKitVideo")
	public Result<String> deleteSalesKitVideo(@RequestParam(name="id",required=true) String id) {
		salesKitVideoService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "Sales Kit Video-批量删除")
	@ApiOperation(value="Sales Kit Video-批量删除", notes="Sales Kit Video-批量删除")
	@DeleteMapping(value = "/deleteBatchSalesKitVideo")
	public Result<String> deleteBatchSalesKitVideo(@RequestParam(name="ids",required=true) String ids) {
	    this.salesKitVideoService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportSalesKitVideo")
    public ModelAndView exportSalesKitVideo(HttpServletRequest request, SalesKitVideo salesKitVideo) {
		 // Step.1 组装查询条件
		 QueryWrapper<SalesKitVideo> queryWrapper = QueryGenerator.initQueryWrapper(salesKitVideo, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<SalesKitVideo> pageList = salesKitVideoService.list(queryWrapper);
		 List<SalesKitVideo> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "Sales Kit Video");
		 mv.addObject(NormalExcelConstants.CLASS, SalesKitVideo.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("Sales Kit Video报表", "导出人:" + sysUser.getRealname(), "Sales Kit Video"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importSalesKitVideo/{mainId}")
    public Result<?> importSalesKitVideo(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<SalesKitVideo> list = ExcelImportUtil.importExcel(file.getInputStream(), SalesKitVideo.class, params);
				 for (SalesKitVideo temp : list) {
                    temp.setMainId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 salesKitVideoService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-Sales Kit Video-end----------------------------------------------*/

    /*--------------------------------子表处理-Sales Kit Document-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "Sales Kit Document-通过主表ID查询")
	@ApiOperation(value="Sales Kit Document-通过主表ID查询", notes="Sales Kit Document-通过主表ID查询")
	@GetMapping(value = "/listSalesKitDocumentByMainId")
    public Result<IPage<SalesKitDocument>> listSalesKitDocumentByMainId(SalesKitDocument salesKitDocument,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<SalesKitDocument> queryWrapper = QueryGenerator.initQueryWrapper(salesKitDocument, req.getParameterMap());
        Page<SalesKitDocument> page = new Page<SalesKitDocument>(pageNo, pageSize);
        IPage<SalesKitDocument> pageList = salesKitDocumentService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param salesKitDocument
	 * @return
	 */
	@AutoLog(value = "Sales Kit Document-添加")
	@ApiOperation(value="Sales Kit Document-添加", notes="Sales Kit Document-添加")
	@PostMapping(value = "/addSalesKitDocument")
	public Result<String> addSalesKitDocument(@RequestBody SalesKitDocument salesKitDocument) {
		salesKitDocumentService.save(salesKitDocument);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param salesKitDocument
	 * @return
	 */
	@AutoLog(value = "Sales Kit Document-编辑")
	@ApiOperation(value="Sales Kit Document-编辑", notes="Sales Kit Document-编辑")
	@RequestMapping(value = "/editSalesKitDocument", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editSalesKitDocument(@RequestBody SalesKitDocument salesKitDocument) {
		salesKitDocumentService.updateById(salesKitDocument);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "Sales Kit Document-通过id删除")
	@ApiOperation(value="Sales Kit Document-通过id删除", notes="Sales Kit Document-通过id删除")
	@DeleteMapping(value = "/deleteSalesKitDocument")
	public Result<String> deleteSalesKitDocument(@RequestParam(name="id",required=true) String id) {
		salesKitDocumentService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "Sales Kit Document-批量删除")
	@ApiOperation(value="Sales Kit Document-批量删除", notes="Sales Kit Document-批量删除")
	@DeleteMapping(value = "/deleteBatchSalesKitDocument")
	public Result<String> deleteBatchSalesKitDocument(@RequestParam(name="ids",required=true) String ids) {
	    this.salesKitDocumentService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportSalesKitDocument")
    public ModelAndView exportSalesKitDocument(HttpServletRequest request, SalesKitDocument salesKitDocument) {
		 // Step.1 组装查询条件
		 QueryWrapper<SalesKitDocument> queryWrapper = QueryGenerator.initQueryWrapper(salesKitDocument, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<SalesKitDocument> pageList = salesKitDocumentService.list(queryWrapper);
		 List<SalesKitDocument> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "Sales Kit Document");
		 mv.addObject(NormalExcelConstants.CLASS, SalesKitDocument.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("Sales Kit Document报表", "导出人:" + sysUser.getRealname(), "Sales Kit Document"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importSalesKitDocument/{mainId}")
    public Result<?> importSalesKitDocument(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<SalesKitDocument> list = ExcelImportUtil.importExcel(file.getInputStream(), SalesKitDocument.class, params);
				 for (SalesKitDocument temp : list) {
                    temp.setMainId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 salesKitDocumentService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-Sales Kit Document-end----------------------------------------------*/

    /*--------------------------------子表处理-Sales Kit FAQ-begin----------------------------------------------*/
	/**
	 * 通过主表ID查询
	 * @return
	 */
	//@AutoLog(value = "Sales Kit FAQ-通过主表ID查询")
	@ApiOperation(value="Sales Kit FAQ-通过主表ID查询", notes="Sales Kit FAQ-通过主表ID查询")
	@GetMapping(value = "/listSalesKitFaqByMainId")
    public Result<IPage<SalesKitFaq>> listSalesKitFaqByMainId(SalesKitFaq salesKitFaq,
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                    HttpServletRequest req) {
        QueryWrapper<SalesKitFaq> queryWrapper = QueryGenerator.initQueryWrapper(salesKitFaq, req.getParameterMap());
        Page<SalesKitFaq> page = new Page<SalesKitFaq>(pageNo, pageSize);
        IPage<SalesKitFaq> pageList = salesKitFaqService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

	/**
	 * 添加
	 * @param salesKitFaq
	 * @return
	 */
	@AutoLog(value = "Sales Kit FAQ-添加")
	@ApiOperation(value="Sales Kit FAQ-添加", notes="Sales Kit FAQ-添加")
	@PostMapping(value = "/addSalesKitFaq")
	public Result<String> addSalesKitFaq(@RequestBody SalesKitFaq salesKitFaq) {
		salesKitFaqService.save(salesKitFaq);
		return Result.OK("添加成功！");
	}

    /**
	 * 编辑
	 * @param salesKitFaq
	 * @return
	 */
	@AutoLog(value = "Sales Kit FAQ-编辑")
	@ApiOperation(value="Sales Kit FAQ-编辑", notes="Sales Kit FAQ-编辑")
	@RequestMapping(value = "/editSalesKitFaq", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> editSalesKitFaq(@RequestBody SalesKitFaq salesKitFaq) {
		salesKitFaqService.updateById(salesKitFaq);
		return Result.OK("编辑成功!");
	}

	/**
	 * 通过id删除
	 * @param id
	 * @return
	 */
	@AutoLog(value = "Sales Kit FAQ-通过id删除")
	@ApiOperation(value="Sales Kit FAQ-通过id删除", notes="Sales Kit FAQ-通过id删除")
	@DeleteMapping(value = "/deleteSalesKitFaq")
	public Result<String> deleteSalesKitFaq(@RequestParam(name="id",required=true) String id) {
		salesKitFaqService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "Sales Kit FAQ-批量删除")
	@ApiOperation(value="Sales Kit FAQ-批量删除", notes="Sales Kit FAQ-批量删除")
	@DeleteMapping(value = "/deleteBatchSalesKitFaq")
	public Result<String> deleteBatchSalesKitFaq(@RequestParam(name="ids",required=true) String ids) {
	    this.salesKitFaqService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

    /**
     * 导出
     * @return
     */
    @RequestMapping(value = "/exportSalesKitFaq")
    public ModelAndView exportSalesKitFaq(HttpServletRequest request, SalesKitFaq salesKitFaq) {
		 // Step.1 组装查询条件
		 QueryWrapper<SalesKitFaq> queryWrapper = QueryGenerator.initQueryWrapper(salesKitFaq, request.getParameterMap());
		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

		 // Step.2 获取导出数据
		 List<SalesKitFaq> pageList = salesKitFaqService.list(queryWrapper);
		 List<SalesKitFaq> exportList = null;

		 // 过滤选中数据
		 String selections = request.getParameter("selections");
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
		 } else {
			 exportList = pageList;
		 }

		 // Step.3 AutoPoi 导出Excel
		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
		 //此处设置的filename无效,前端会重更新设置一下
		 mv.addObject(NormalExcelConstants.FILE_NAME, "Sales Kit FAQ");
		 mv.addObject(NormalExcelConstants.CLASS, SalesKitFaq.class);
		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("Sales Kit FAQ报表", "导出人:" + sysUser.getRealname(), "Sales Kit FAQ"));
		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
		 return mv;
    }

    /**
     * 导入
     * @return
     */
    @RequestMapping(value = "/importSalesKitFaq/{mainId}")
    public Result<?> importSalesKitFaq(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
       // 获取上传文件对象
			 MultipartFile file = entity.getValue();
			 ImportParams params = new ImportParams();
			 params.setTitleRows(2);
			 params.setHeadRows(1);
			 params.setNeedSave(true);
			 try {
				 List<SalesKitFaq> list = ExcelImportUtil.importExcel(file.getInputStream(), SalesKitFaq.class, params);
				 for (SalesKitFaq temp : list) {
                    temp.setMainId(mainId);
				 }
				 long start = System.currentTimeMillis();
				 salesKitFaqService.saveBatch(list);
				 log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
				 return Result.OK("文件导入成功！数据行数：" + list.size());
			 } catch (Exception e) {
				 log.error(e.getMessage(), e);
				 return Result.error("文件导入失败:" + e.getMessage());
			 } finally {
				 try {
					 file.getInputStream().close();
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.error("文件导入失败！");
    }

    /*--------------------------------子表处理-Sales Kit FAQ-end----------------------------------------------*/




}
